package com.yt.system.dao;

import com.yt.system.domain.Objective;
import com.yt.system.domain.ObjectiveKeyresults;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ObjectiveMapper {


    //3.根据uid查询个人okr
//    @Select("SELECT o.oid, o.ocontent, k.krcontent, k.krid, k.oid FROM objective o LEFT JOIN keyresults k ON o.oid = k.oid LEFT JOIN account a  ON o.oid=a.oid LEFT JOIN user u  ON a.aid=u.uid WHERE u.uid=#{uid};")
    @Select("SELECT *  FROM objective o  LEFT JOIN keyresults k ON o.oid = k.oid  WHERE o.uid= #{uid};")
    List<ObjectiveKeyresults> selectOkr(int uid);

    //更新O
    @Update("update objective set ocontent = #{ocontent},excellent = #{excellent},createdata = #{createdata} where oid =#{oid}")
    int UpdO(Objective obj);

    //插入O
    @Insert("INSERT INTO objective(ocontent,uid,excellent,createdata) value ( #{ocontent},#{uid},#{excellent},#{createdata})")
    int InsO(Objective obj);

    //删除O
    @Delete("delete from objective where oid = #{value}")
    int DelO(int id);

    //优秀OKR
    @Update("update objective set excellent = #{excellent} where oid =#{oid}")
    int UpdateExcellentOkr(Objective obj);
    //评价
    @Update("update objective set comment = #{comment} where oid =#{oid}")
    int UpdateComment(Objective obj);


}